# 导包
import jsonschema

# 编写 数据规则 schema
schema = {
    "type": "object",
    "properties": {
        "success": {
            "type": "boolean"
        },
        "code": {
            "type": "integer"
        },
        "message": {
            "type": "string"
        }
    },
    "required": ["success", "code", "message"]
}

data = {
    "success": True,
    "code": 10000,
    "message": "操作成功"
}


# 调用validate方法去检查
# 返回值：None 代表校验通过
# ValidationError  数据错误
# SchemaError 数据规则错误 schema出错

result = jsonschema.validate(instance=data, schema=schema)
print(result)